package com.ccubee.data.transfer.transfer.type.impl;

import com.ccubee.data.transfer.event.ColumnData;
import com.ccubee.data.transfer.transfer.type.IType;
import com.ccubee.data.transfer.types.ColumnType;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.sql.ResultSet;

/**
 * 默认
 *
 * @Author ycf
 * @Date 2022/11/16 21:38
 * @Version 1.0
 */
@Component
@Slf4j
public class TypeNone implements IType {
    @Override
    public ColumnType type() {
        return ColumnType.NONE;
    }

    @SneakyThrows
    @Override
    public Object apply(ColumnData columnData, ResultSet resultSet) {
        Object object = resultSet.getObject(columnData.getName());
        if (object instanceof String) {
            return object;
        } else {
            return resultSet.getString(columnData.getName());
        }
    }
}
